package path

import (
	"fmt"
	"log"
	"os"
	"strings"
)

var (
	ComPath         string //公共目录
	ConfPath        string // 配置目录
	CtlPath         string // 控制器层目录
	DbPath          string // 数据库目录
	PucPath         string // 静态资源目录
	StcPath         string // 静态目录下static
	sevPath         string // 逻辑层目录
	VefPath         string // 验证层层目录
	BasePath        string // 根目录
	SessPath        string // session 目录
	AdminUploadFile string // 上传目录
	ApiUploadFile   string // 上传目录
	LogPath         string // 日志目录
	KeysPath        string // 微信密钥位置
)

func DirInit() {
	// 获取当前工作目录
	projectDir, err := os.Getwd()
	if err != nil {
		log.Fatalf("Failed to get project directory:%v", err)
	}

	dir := strings.Replace(projectDir, "\\", "/", -1)

	ComPath = fmt.Sprintf(dir+"/%s", "common")
	ConfPath = fmt.Sprintf(dir+"/%s", "common")
	CtlPath = fmt.Sprintf(dir+"/%s", "controller")
	DbPath = fmt.Sprintf(dir+"/%s", "database")
	PucPath = fmt.Sprintf(dir+"/%s", "public")
	StcPath = fmt.Sprintf(dir+"/%s", "public/static")
	AdminUploadFile = fmt.Sprintf(PucPath+"/%s", "upload/uadmin")
	ApiUploadFile = fmt.Sprintf(PucPath+"/%s", "upload/uapi")
	sevPath = fmt.Sprintf(dir+"/%s", "service")
	VefPath = fmt.Sprintf(dir+"/%s", "verify")
	SessPath = fmt.Sprintf(dir+"/%s", "session")
	LogPath = fmt.Sprintf(dir+"/%s", "log")
	KeysPath = fmt.Sprintf(dir+"/%s", "public/weChatKeys")
	BasePath = dir
}
